package com.productivity.model;

import com.productivity.model.animation.Animation;
import com.productivity.model.animation.AnimationListener;
import com.productivity.model.animation.AnimationType;
import com.productivity.model.common.Direction;
import com.productivity.model.common.DrawType;
import com.productivity.model.common.Size3D;
import com.productivity.model.common.Vector3D;
import com.productivity.model.common.Vertex3D;

public class Enemy extends DynamicGameObject implements AnimationListener  {

	private float[] verts = {0.00000f, -0.00000f, 0.64952f, -0.37500f, 0.64952f, -0.37500f, 0.64952f, -1.12500f, 0.00000f, -0.00000f, -0.64952f, -0.37500f, -0.64952f, -0.37500f, -0.64952f, -1.12500f, 0.00000f, -0.00000f, 0.00000f, -1.00000f, 0.00000f, -1.00000f, -0.50000f, -1.86603f, -0.50000f, -1.86603f, -0.50000f, -2.86603f, 0.00000f, -1.00000f, 0.50000f, -1.86603f, 0.50000f, -1.86603f, 0.50000f, -2.86603f };
	private Animation currAnimation;
	private Vector3D direction;
	private boolean dead;

	public Enemy(Vertex3D loc) {
		currAnimation = null;
		direction = new Vector3D();
		velocity = new Vertex3D();
		location = loc;
		vertices = new Vertex3D[18];
		size = new Size3D(0.4f,2.4f,1);
		drawOffset = new Vertex3D(0,size.getY()/2,0);
		
		for(int i = 0; i < vertices.length; i++)
			vertices[i] = new Vertex3D(verts[i*3],verts[i*3+1],verts[i*3+2]);
	}

	@Override
	public void update(Map map) {
		location.setY(location.getY()+velocity.getY());
		location.setX(location.getX()+velocity.getX());
		
		
		if(currAnimation!=null) {
			vertices = currAnimation.getInterFrame();
			currAnimation.update();
		}
	}
	public boolean isDead() {
		return dead;
	}

	public void setDead(boolean dead) {
		this.dead = dead;
	}
	public void die() {
		
	}

	@Override
	public DrawType getDrawType() {
		return DrawType.LINE;
	}

	@Override
	public Size3D getModelSize() {
		return new Size3D(0.5f,2.9f,1);
	}

	@Override
	public void animationFinished(AnimationType type) {
		if(type == AnimationType.KICKED)
			dead = true;
		
	}

}
